package com.javaIO.demo2;

import java.io.*;

public class Test1 {
    public static void main(String[] args) throws IOException {

        FileOutputStream outputStream = new FileOutputStream("D:\\SoftDevelopment\\Java\\file\\test.txt");

        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
        char[] chars1 = {'q','w','d','d'};
        outputStreamWriter.write("华为666666");
        outputStreamWriter.write("华为666666",1,3);
        outputStreamWriter.write('a');
        outputStreamWriter.write(chars1);
        outputStreamWriter.write(chars1,1,3);
        outputStreamWriter.close();
        System.out.println("---------------------------------");



        FileInputStream inputStream = new FileInputStream("D:\\SoftDevelopment\\Java\\file\\test.txt");
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
        char[] chars = new char[1024];
        int len;
        while ((len = inputStreamReader.read(chars)) != -1) {
            System.out.println(new String(chars, 0, len));
        }
        inputStreamReader.close();
    }
}
